home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 …ember: Reference Library / Dev.CD Dec 00 RL Disk 1.toast / pc / technical documentation / develop / additional articles / timing on the macintosh / timing code / src / microsecondtrappresent.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-17  |  958 b   |  52 lines

  1. /*                                MicrosecondTrapPresent.c                        */
  2. /*
  3.  * MicrosecondTrapPresent.c
  4.  * Copyright © 1992-94 Apple Computer Inc.
  5.  */
  6. #include <OSUtils.h>
  7. #include "MicrosecondTrap.h"
  8.  
  9. static Boolean                TrapAvailable(
  10.         short                    theTrap
  11.     );
  12.  
  13. Boolean
  14. MicrosecondTrapPresent(void)
  15. {
  16.         return (TrapAvailable(_Microseconds));
  17. }
  18.  
  19. /*
  20.  * TrapAvailable (see Inside Mac VI 3-8)
  21.  */
  22. #define NumToolboxTraps() (                                \
  23.         (NGetTrapAddress(_InitGraf, ToolTrap)            \
  24.                 == NGetTrapAddress(0xAA6E, ToolTrap))    \
  25.             ? 0x200 : 0x400                                \
  26.     )
  27. #define GetTrapType(theTrap) (                            \
  28.         (((theTrap) & 0x800 != 0)) ? ToolTrap : OSTrap    \
  29.     )
  30.  
  31. static Boolean
  32. TrapAvailable(
  33.         short                    theTrap
  34.     )
  35. {
  36.         TrapType                trapType;
  37.         
  38.         trapType = GetTrapType(theTrap);
  39.         if (trapType == ToolTrap) {
  40.             theTrap &= 0x07FF;
  41.             if (theTrap >= NumToolboxTraps())
  42.                 theTrap = _Unimplemented;
  43.         }
  44.         return (
  45.             NGetTrapAddress(theTrap, trapType)
  46.             != NGetTrapAddress(_Unimplemented, ToolTrap)
  47.         );
  48. }
  49.  
  50.  
  51.  
  52.